<?php

namespace App\Models\Kms\Task;

use App\Models\BaseModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopMainProcessModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasOne;

class DailyTaskLogsModel extends BaseModel
{
    use HasFactory;

    protected $table = "kms_daily_task_logs";

    const TASK_TYPE_1    = 1;
    const TASK_TYPE_2    = 2;
    const TASK_TYPE_3    = 3;
    const TASK_TYPE_4    = 4;
    const TASK_TYPE_5    = 5;
    const TASK_TYPE_TEXT = [
        self::TASK_TYPE_1 => "差评维护",
        self::TASK_TYPE_2 => "稽核整改",
        self::TASK_TYPE_3 => "门店活动洽谈",
        self::TASK_TYPE_4 => "客诉处理",
        self::TASK_TYPE_5 => "其他",
    ];

    protected $fillable = [
        "uniqueSign",
        "shopId",
        "handlerUserId",
        "approveUserIds",
        "taskType",
        "desc",
        "descImg",
        "createdAt",
        "createdByUid",
        "updatedAt",
        "updatedByUid",
        "isDeleted"
    ];

    /**
     * @return HasOne
     */
    public function taskRel(): HasOne
    {
        return $this->hasOne(TaskModel::class, "businessId", "id");
    }

    /**
     * @return HasOne
     */
    public function mainProcessRel(): HasOne
    {
        return $this->hasOne(OpenShopMainProcessModel::class, "shopId", "shopId");
    }
}
